package com.faceye.core;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class MVCConfiguration {
//	@Bean
//	public FilterRegistrationBean filterRegistrationBean(){
//		UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
//		CorsConfiguration conf=new CorsConfiguration();
//		conf.addAllowedOrigin("*");
//		conf.addAllowedOrigin("Access-Control-Allow-Origin:*");
//		conf.addAllowedHeader("*");
//		conf.addAllowedHeader("Access-Control-Allow-Headers:Authorization,Origin,X-Requested-With,Content-Type,Accept");
//		conf.addAllowedMethod("*");
//		conf.addAllowedMethod("GET");
//		conf.addAllowedMethod("POST");
//		conf.addAllowedMethod("PUT");
//		conf.addAllowedMethod("DELETE");
//		conf.addAllowedMethod("OPTIONS");
//		conf.setAllowCredentials(true);
//		source.registerCorsConfiguration("/**", conf);
//		FilterRegistrationBean bean=new FilterRegistrationBean(new CorsFilter(source));
//		bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
//		return bean;
//	}
}
